<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <title>小区审核</title>

    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
 	<script src="${pageContext.request.contextPath}/static/js/global.js"></script>
    <style type="text/css">
        .main h5 a {
            position: absolute;
            right: 20px;
            font-size: 14px;
            bottom: 0px;
            display: inline-block;
            padding: 5px;
        }

        .table_list tbody tr {
            height: 35px;
            text-align: center;
        }
			.left ul li{
			
			*line-height:40px;
			
			*padding-left:20px;
		}
		
		.left ul li a, .left ul li a:hover{
			*color:#fff;
		}
		.list-tab li{
			*+padding:0px 10px 10px;
		}
		.jqGrid_wrapper{
			*margin-left:250px;
		}
    </style>
</head>
<body view="menu-item-4142">
<jsp:include page="../../top.jsp"></jsp:include>
<div class="right">
    <div class="jqGrid_wrapper">
        <div id="jqGrid_operation" class="jg-grid">
            <h1>小区审核</h1>
            <div class="jqGrid_operation" id="action"></div>
        </div>
        <table id="jqGrid"></table>
        <div id="jqGrid_paper"></div>
    </div>
</div>
<script>
    $(document).ready(
            function () {

                $.jgrid.defaults.styleUI = "Bootstrap";
                $("#jqGrid").jqGrid(
                        {
                            url: "${pageContext.request.contextPath}/admin/tcommunity_auditList.action?agtCode=${agtCode}",
                            mtype: 'POST',
                            datatype: "json",
                            height:450,
                            autowidth: true,
                            shrinkToFit: true,
                            rowNum: 10,
                            rowList: [10, 20, 30],
                            colNames: ['序号', '所属区域', '公司名称', '小区名称', '帐号', '负责人',
                                '联系方式 ', '地址 ', '申请时间', '审核时间', '审核人', '状态', '备注', '操作'],
                            colModel: [{
                                name: "SID",
                                index: "SID",
                                key: true,
                                hidden: true
                            },{
                                name: 'CITYCODE',
                                index: 'CITYCODE',
                                width: 80
                            },{
                                name: 'AGTNAME',
                                index: 'AGTNAME',
                                width: 100
                            },{
                                name: 'COMMUNITYNAME',
                                index: 'COMMUNITYNAME',
                                width: 100
                            },{
                                name: 'ADMINUSER',
                                index: 'ADMINUSER',
                                width: 80
                            },{
                                name: 'COMCONTACT',
                                index: 'COMCONTACT',
                                width: 80
                            },{
                                name: 'DEPARTTEL',
                                index: 'DEPARTTEL',
                                width: 80
                            },{
                                name: 'STREET',
                                index: 'STREET',
                                width: 80
                            }, {
                                name: 'CTIME',
                                index: 'CTIME',
                                width: 80
                            }, {
                                name: 'ATIME',
                                width: 80,
                                index: 'ATIME'
                            },{
                                name: 'AUSERNAME',
                                index: 'AUSERNAME',
                                width: 80
                            },{
                                name: "STATUS",
                                index: "STATUS",
                                width: 65,
                                formatter: "select",
                                editoptions: {value: "-1:;0:待审核;1:审核通过;2:审核拒绝;3:候审;"}
                            },{
                                name: 'COMM',
                                width: 80,
                                index: 'COMM',
                                formatter: function (cellvalue, options, rawObject) {
                                  	 if(!cellvalue){
                                         return '';
                                     }else if(cellvalue == '-1'){
                                       	 return '';
                                     }else if(cellvalue.substring(0,2)=='()'){
                                         return cellvalue.substring(2,cellvalue.length);
                                     }else{
                                    	 return cellvalue;
                                     }
                                  }
                            },{
                                name: 'STATUS',
                                index: 'STATUS',
                                width: 160,
                                formatter: function (cellvalue, options, rawObject) {
                                 switch (cellvalue) {
                                     case "0":
                                     case "3":
                                       return '<input type="button" style="padding: 2px 10px" class="btn btn-success" value="拒绝 " onclick="refuse('
                                                     + rawObject.SID + ',2)"/><input type="button" style="padding: 2px 10px" class="btn btn-success" value="候审" onclick="refuse('
                                                     + rawObject.SID + ',3)"/><input type="button" style="padding: 2px 10px" class="btn btn-success" value="通过" onclick="pass('
                                                     + rawObject.SID + ')"/>';
                                     	break;
                                     case "1":
                                         return "审核通过";
                                         break;
                                     case "2":
                                         return "审核拒绝";
                                         break;
                                     case "-1":
                                         return "";
                                         break;
                                 	}
                             	}
                            }],
                            sortname: 'sid',
                            sortorder:'desc',
                            rownumbers: true,
                            jsonReader: {
                                root: 'rows',
                                page: "page",
                                total: 'total',
                                records: "records",
                                repeatitems: false
                            },
                            pager: "#jqGrid_paper",
                            viewrecords: true,
                            multiselect: true,
                            hidegrid: false,
                            loadComplete: function(){
                        		var re_records = Number($("#jqGrid").getGridParam('records'));
                        		var page = Number($("#jqGrid").getGridParam('page'));
                        		var rows=Number($("#jqGrid").getGridParam('rowNum'));
                        		var num = re_records-(page-1)*rows;
                        		if(num < rows)
                        		{
                        			for(var i=num;i<rows;i++){
                        				$("#jqGrid").jqGrid("addRowData",(i+1),
                                				{ "SID":"", "CTIME":"", "CITYCODE":"", "COMMUNITYNAME":"", "ADMINUSER":"","COMCONTACT":"","DEPARTTEL":"","STREET":"","STATUS":"-1","AUSERNAME":"","ATIME":"","COMM":"-1","STATUS":"-1"}
                        				,"");
                        			}
                        			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
                        		}
                        	}
                        });
            });

    <!--刷新jqGrid表格数据-->
    function refreshGrid() {
        $("#jqGrid").trigger("reloadGrid");
    }
    
    function audit(sid,status){
	   	$.post("${pageContext.request.contextPath}/admin/tcommunity_audit.action", {
	   		'sid': sid,
         	'status': status
         }, function (result) {
             result = JSON.parse(result)
             if (result.code == 1 || result.code == 2) {
                 refreshGrid();
             } 
             layer.alert(result.msg);
         });
   	 }
  	 
    function pass(sid){
    	layer.open({
            type: 2,
            title: '<strong>选择APP</strong>',
            shadeClose: true, //点击遮罩关闭层
            area: ['700px', '330px'],
            content: '${pageContext.request.contextPath}/admin/appstore_selectApp.action?sid='
            + sid,
            btn: ['提交', '取消'],
            yes: function (index, layero) {
                var options = {
                    success: function (data) {
                        data = JSON.parse(data);
                        if (data.code == 1) {
                            layer.alert(data.msg, function () {
                                layer.closeAll();
                            });
                        } else {
                            layer.alert(data.msg);
                        }
                        refreshGrid();
                    }
                };
                var appSid = $("#layui-layer-iframe" + index).contents().find("#appSid").val();
                if(appSid != ''){
	                $("#layui-layer-iframe" + index).contents().find("#form").ajaxForm(options);
	                $("#layui-layer-iframe" + index).contents().find("#form").submit();
                }else{
                	alert("APP必须选择！");
                }
            }
        });
    }
    function refuse(sid,status){
    	layer.open({
            type: 2,
            title: '<strong>拒绝原因</strong>',
            shadeClose: true, //点击遮罩关闭层
            area: ['700px', '330px'],
            content: '${pageContext.request.contextPath}/admin/tcommunity_refuse.action?sid='
            + sid+'&status='+status,
            btn: ['提交', '取消'],
            yes: function (index, layero) {
                var options = {
                    success: function (data) {
                        data = JSON.parse(data);
                        if (data.code == 1) {
                            layer.alert(data.msg, function () {
                                layer.closeAll();
                            });
                        } else {
                            layer.alert(data.msg);
                        }
                        refreshGrid();
                    }
                };
                $("#layui-layer-iframe" + index).contents().find("#form").ajaxForm(options);
                $("#layui-layer-iframe" + index).contents().find("#form").submit();
            }
        });
    };
			window.onload=function(){
		function BrowserType(){
			//获取浏览器的userAgent代理号；
			var userAgent=navigator.userAgent;
			
			//判断是否是Opera浏览器
			var isOpera=userAgent.indexOf("Opera")>-1;
			//判断是否是IE浏览器
			var isIE=userAgent.indexOf("compatible")>-1 && userAgent.indexOf("MSIE")>-1 && !isOpera;
			//判断是否是IE7浏览器
			if(isIE){
				var relIE=new RegExp("MSIE(\\d+\\.\\d+);");
				
				relIE.test(userAgent);
				var arr=userAgent.split(";")
				var flEVersion=arr[1].indexOf("7");
				if(flEVersion>-1){
					$tr=$("thead tr th");
					var t=$("tbody tr")[2];
					
					var d=t.getElementsByTagName("td");
					d[0].style.width=10+"px";
					$td=$("tbody tr td");
					var len=$tr.length;
					for(var i=0;i<len;i++){
						$tr[i].style.width=30+"px";
						
						$td[i].style.width=30+"px";
						
					};
				}
			}
		};
		BrowserType();
	};
</script>
</body>
</html>
